#ifndef __BSP_FLASH_H
#define __BSP_FLASH_H

#include "ch32f10x.h"
#include "stdio.h"	
#define FLASH_PAGE_SIZE                   1024

extern uint32_t flashOffset;


#define FLASH_USB_numberlen_ADDR 	0x08009000
#define FLASH_USB_namelen_ADDR   	0x08009500
#define FLASH_name_ADDR          	0x08006000
#define FLASH_number_ADDR        	0x08007000 
#define FLASH_ipSAVE_ADDR        	0x08008000
#define FLASH_time_ADDR          	0x08006500


int  U8toU32(uint32_t *Buf32,uint8_t *Buf8,int len);
void Flash_writeBuf(uint32_t Address, uint32_t *buf, int len);
void FLASH_EraseApp(void);


void Flash_writeFlag(uint16_t ver);
uint16_t Flash_readFlag(void);
	
void Flash_writeVersion(uint16_t ver);
uint16_t Flash_readVersion(void);

uint32_t Flash_readBaudIndex(void);
void getAllParam(void);

uint32_t STMFLASH_ReadWord(uint32_t faddr);
void FLASH_Read(u32 ReadAddr,u32 *pBuffer,u32 NumToRead);
void Flash_writeDATA(uint32_t Address, uint32_t *DATA);
void FLASH_ReadDATA(uint32_t ReadAddr,uint32_t *DATA);

#endif
